Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[readState] tolerant short delay when read from contract staking indexer #4458

Merged
merged 7 commits into from
Nov 21, 2024

Conversation

envestcc
Copy link
Member

Description

Currently, the height of the indexer may briefly lag behind BlockDAO by 1, which can result in errors when querying the indexer.

To avoid this issue, we should increase a short waiting time when querying data from the indexer if we find that the height is behind.

In the specific implementation, we have introduced delayTolerantIndexer to implement this feature by wrapping the underlying indexer.

Type of change

Please delete options that are not relevant.

  • Code refactor or improvement

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

if indexWithStart.StartHeight() >= height {
return false, nil
}
}
Copy link
Member

@dustinxie dustinxie Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a startHeight in delayTolerantIndexer struct, and move this type assertion (and save its start height) when creating the instance one-time, so can directly use the value here:

if c.startHeight >= height {
    return false, nil
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link

sonarcloud bot commented Nov 21, 2024

@dustinxie dustinxie merged commit 60c2a3a into iotexproject:master Nov 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants